/*
 * Copyright © 2017 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

@import "../../styles/variables.less";

@text-color: #333333;
@border-color: #cccccc;
@active-bg-color: #eeeeee;
@input-box-focus-color: #66afe9;
@input-label-color: #999999;
@action-button-color: #666666;
@modeless-bg-color: lightgray;
@modeless-header-bg-color: #f5f5f5;
@modeless-width: 830px;
@modeless-height: 496px;
@side-panel-width: 170px;
@regular-font: 14px;
@secondary-btn-color: @brand-primary;

body.theme-cdap {
  &.state-hydrator {
    .pipeline-configurations-content {
      background: @modeless-bg-color;
      position: fixed;
      top: 95px;
      overflow: auto;
      right: 15px;
      z-index: 999;
      box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
      color: @text-color;
      background-color: white;
      width: @modeless-width;
      height: @modeless-height;

      .pipeline-configurations-header {
        background-color: @modeless-header-bg-color;
        height: 60px;
        padding: 0;
        border-radius: 4px 4px 0 0;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .modeless-title {
          color: @text-color;
          padding-left: 15px;
          max-width: 80%;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          font-weight: 500;
          margin: 0 auto 0 0;
          font-size: 16px;
          line-height: 20px;
        }

        .btn .fa-remove {
          color: @text-color;
          font-size: 16px;
        }
      }

      .pipeline-configurations-body {
        display: flex;

        /* 60px: height of modeless box header */
        height: ~"calc(100% - 60px)";
        height: ~"-moz-calc(100% - 60px)";
        height: ~"-webkit-calc(100% - 60px)";

        .configurations-side-panel {
          border-right: 1px solid @border-color;
          border-top: 1px solid @border-color;

          .configurations-headers {
            .configuration-header {
              height: 40px;
              display: flex;
              align-items: center;
              padding-left: 23px;
              font-size: @regular-font;
              cursor: pointer;
              width: @side-panel-width;
              border-bottom: 1px solid @border-color;

              &:hover {
                color: @cdap-orange;
              }

              &.active {
                background-color: @active-bg-color;
                color: @cdap-orange;
                font-weight: bold;
              }

              &.disabled {
                pointer-events: none;
                color: lighten(@text-color, 60%);
              }

              &.toggle-advanced-options {
                padding-left: 0;

                span.fa {
                  display: inline-block;
                  width: 23px;
                  text-align: center;
                }
              }
            }
          }
        }

        .configuration-content {
          width: 100%;
          margin: 16px 30px 40px 50px;
          font-size: @regular-font;
          position: relative;

          .configuration-content-container {
            /* 50px: height from bottom of buttons to horizontal line */
            height: ~"calc(100% - 50px)";
            height: ~"-moz-calc(100% - 50px)";
            height: ~"-webkit-calc(100% - 50px)";
            border-bottom: 1px solid @border-color;

            .configuration-step-content {
              height: 100%;
            }
          }

          .configuration-step-content {
            .step-content-heading {
              font-weight: bold;
              margin-bottom: 16px;

              .step-content-subtitle {
                font-weight: initial;
                font-size: 12px;
              }
            }

            .label-with-toggle {
              margin-bottom: 15px;
              display: flex;
              align-items: center;

              .toggle-label {
                text-align: right;
                padding-right: 0;
              }

              .toggle-container {
                display: flex;
                align-items: center;

                .fa.fa-info-circle {
                  margin-left: 10px;
                }
              }

              .small-dropdown {
                width: 65px;
                display: inline-block;
              }
            }

            .key-value-pair-labels {
              .key-label,
              .value-label,
              .provided-label {
                display: inline-block;
                color: @input-label-color;
                width: 40%;
                font-weight: 500;
              }

              .key-label {
                margin-right: 22px;
              }
            }

            .key-value-pair-values {
              margin-top: 10px;

              .key-value-pair-preference {
                margin-bottom: 16px;
                justify-content: initial;

                input[type="text"] {
                  border: 1px solid @border-color;
                  border-radius: 0.25rem;
                  font-size: @regular-font;

                  &:focus {
                    border-color: @input-box-focus-color;
                  }
                }

                .btn-link {
                  color: @action-button-color;
                  font-size: @regular-font;
                  padding: 6px 10px;
                }
              }
            }

            .fa.fa-info-circle {
              margin-left: 5px;
            }

            &.runtime-arguments {
              .runtime-arguments-labels {
                .key-label {
                  width: 34%;
                }

                .value-label {
                  width: 44%;
                }

                .provided-label {
                  width: initial;
                }
              }

              .runtime-arguments-values {
                /* 192px = 32px (height of input box) * 4
                         + 16px (margin between each boxes) * 4 */
                max-height: 192px;
                overflow-x: hidden;
                overflow-y: auto;

                .key-value-pair-preference {
                  input[type="text"] {
                    width: 35%;
                  }

                  input[type="checkbox"] {
                    width: 12px;
                    height: 12px;
                    display: inline-block;
                    margin: 0 16px 0 8px;
                  }

                  .btn-link {
                    padding: 6px 8px;
                  }
                }
              }
            }

            &.engine-config {
              .engine-config-radio {
                padding-top: 10px;

                .radio-spark {
                  margin-right: 80px;
                }
              }

              .add-custom-config {
                margin-top: 25px;

                a {
                  cursor: pointer;

                  &.add-custom-config-label {
                    margin-top: 5px;
                  }

                  .fa.fa-caret-down,
                  .fa.fa-caret-right {
                    width: 8px;
                    color: @text-color;
                  }
                }

                hr {
                  margin-bottom: 12px;
                }

                .custom-config-values {
                  /* 144px = 32px (height of input box) * 3
                           + 16px (margin between each boxes) * 3 */
                  max-height: 144px;
                  overflow-x: hidden;
                  overflow-y: auto;
                }

                .num-rows {
                  color: @input-label-color;
                }
              }
            }

            &.resources {
              .client,
              .driver,
              .executor {
                padding-left: 0;
              }

              .client,
              .driver {
                border-right: 1px solid @input-label-color;
              }

              .resource-title {
                font-weight: 500;
              }

              .resource-holder {
                .resource-group {
                  display: flex;
                  align-items: center;
                  margin-top: 15px;

                  .small-dropdown,
                  my-number-widget input {
                    width: 60px;
                    padding-right: 0;
                    padding-left: 5px;
                  }

                  .control-label {
                    text-align: right;
                    padding-right: 0;
                    margin-right: 10px;

                    &.mb {
                      margin-left: 5px;
                    }
                  }
                }
              }
            }
          }

          .configuration-step-navigation {
            position: absolute;
            bottom: 0;
            width: 100%;

            .btn {
              font-size: @regular-font;

              &.btn-secondary {
                color: @secondary-btn-color;
              }

              &.apply-run {
                margin-right: 16px;
              }

              &.apply-close {
                width: 100px;
              }
            }

            .apply-run-container {
              display: flex;
              align-items: center;

              .num-runtime-args {
                color: @input-label-color;
                margin-left: auto;
              }
            }
          }
        }
      }
    }
  }
}
